/*
 * Eugen Stoian <stoian.e@gmail.com> 2010
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef PARAMETRIC3DFORM_H
#define PARAMETRIC3DFORM_H

#include <QtGui/QWidget>

namespace Ui {
    class Parametric3DForm;
}
class ParametricObject3D;
class Expression3D;
class AutoParametersModel;
class FixedParametersModel;
class Parameter;
class Project;
class Parametric3DForm : public QWidget {
    Q_OBJECT
public:
    Parametric3DForm(QWidget *parent = 0);
    virtual ~Parametric3DForm();
    bool isModified() const {
        return _modified;
    }
    ParametricObject3D* object();
protected:
    void changeEvent(QEvent *e);
    void loadParameters();
    void loadExpression();
    void loadColor();
public slots:
    void setObject(ParametricObject3D *object);
    void apply();
    void revert();
protected slots:
    void onParametersChanged();
    void onNameChanged(const QString& name);
    void onColorButtonClicked();
    void onGetExpressionButtonClicked();
    void onNewExpressionButtonClicked();
    void onGoAutoClicked();
    void onGoFixedClicked();
signals:
    void modified(bool);
private:
    void init();
    void cleanUpParams();
    void initParamsFromObject();
    void initParamsFromExpression();
private:
    Ui::Parametric3DForm * m_ui;
    ParametricObject3D *_object;
    Project * _project;
    QString _objectName;
    const Expression3D * _expression;
    QColor _color;
    bool _parametersChanged;
    QList<Parameter*> _autoParameters;
    QList<Parameter*> _fixedParameters;
    AutoParametersModel* _autoParametersModel;
    FixedParametersModel* _fixedParametersModel;
    bool _modified;
};

#endif // PARAMETRIC3DFORM_H
